// @Author EthanScriptOn
// @Desc
package custom_exp

import (
	"fmt"
)

const NO_RESOURCE_TEMPLATE_RESOURCE_ID = "Resource with ID '%s' not found Error at \n%s\n"
const NO_RESOURCE_TEMPLATE = "Resource not found Error at \n%s\n"

// NoResourceError The resource could not find an exception
type NoResourceError struct {
	err        error
	resourceID interface{}
}

func (n NoResourceError) Error() string {
	if n.resourceID != nil {
		return fmt.Sprintf(NO_RESOURCE_TEMPLATE_RESOURCE_ID, n.resourceID, n.err)
	}
	return fmt.Sprintf(NO_RESOURCE_TEMPLATE, n.err)
}

func GenerateNoResourceError(resourceId interface{}, err error) *NoResourceError {
	instance := new(NoResourceError)
	instance.resourceID = resourceId
	instance.err = err
	return instance
}

func GenerateNoResourceErrorWithErr(err error) *NoResourceError {
	instance := new(NoResourceError)
	instance.err = err
	return instance
}
